<extend name="../application/admin/view/common/base.html" />
<block name="x-nav"><a><cite>修改密码</cite></a></block>
<block name="body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="L_pass" class="layui-form-label">
                <span class="x-red">*</span>渠道名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_pass" name="name" required=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red"></span>登录用户名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="username" name="username" required=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="password" class="layui-form-label">
                <span class="x-red"></span>密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="password" name="password" required=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="password" class="layui-form-label">
                <span class="x-red"></span>扣量(%)
            </label>
            <div class="layui-input-inline">
                <input type="number" id="reduce" name="reduce" required=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="mobile" class="layui-form-label">
                联系电话
            </label>
            <div class="layui-input-inline">
                <input type="text" id="mobile" name="mobile" required=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>
    </form>
</block>
<block name="bottom">
    <script>
        layui.use(['form','layer','upload'], function(){
            $ = layui.jquery;
            var form = layui.form
                ,layer = layui.layer
                ,upload = layui.upload;

            //监听提交
            form.on('submit(add)', function(data){
                var params = new URLSearchParams();
                $.each(data.field,function (k,v) {
                    params.append(k,v);
                })
                instance.post('/admin/channel.add.do',params)
                    .then(function (response) {
                        var data = response.data;
                        if(data.status == 1){
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            parent.location.reload();
                        }else{
                            _alert(data.msg);
                        }
                    })
                    .catch(function (error) {
                        console.log(error)
                    });
                return false;
            });


        });
    </script>
</block>